package com.cy.myblog.model;

import org.apache.struts2.json.annotations.JSON;

import javax.persistence.*;
import java.util.HashSet;
import java.util.Set;
/**
 * Created by Administrator on 2015/7/13.
 */
@Entity
@Table(name = "tmenu")
public class Tmenu implements java.io.Serializable
{

    private String     id;
    private Tmenu      tmenu;
    private String     name;
    private String     url;
    private String     click;
    private String     parameter;
    private Set<Tmenu> children = new HashSet<Tmenu>(0);

    // Constructors

    /** default constructor */
    public Tmenu()
    {
    }

    /** minimal constructor */
    public Tmenu(String id)
    {
        this.id = id;
    }

    /** full constructor */
    public Tmenu(String id, Tmenu tmenu, String name, String url, String parameter, Set<Tmenu> children)
    {
        this.id = id;
        this.tmenu = tmenu;
        this.name = name;
        this.url = url;
        this.parameter = parameter;
        this.children = children;
    }

    @Id
    @Column(name = "id", unique = true, nullable = false, length = 36)
    public String getId()
    {
        return this.id;
    }

    public void setId(String id)
    {
        this.id = id;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "pid")
    @JSON(serialize=false)
    public Tmenu getTmenu()
    {
        return this.tmenu;
    }

    public void setTmenu(Tmenu tmenu)
    {
        this.tmenu = tmenu;
    }

    @Column(name = "name", length = 100)
    public String getName()
    {
        return this.name;
    }

    public void setName(String name)
    {
        this.name = name;
    }

    @Column(name = "url", length = 200)
    public String getUrl()
    {
        return this.url;
    }

    public void setUrl(String url)
    {
        this.url = url;
    }

    public String getClick() {
        return click;
    }

    public void setClick(String click) {
        this.click = click;
    }

    public String getParameter() {
        return parameter;
    }

    public void setParameter(String parameter) {
        this.parameter = parameter;
    }

    @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "tmenu")
    public Set<Tmenu> getChildren()
    {
        return this.children;
    }

    public void setChildren(Set<Tmenu> children)
    {
        this.children = children;
    }

    @Override
    public String toString()
    {
        return "Tmenu [id=" + id + ", name=" + name + ", url=" + url + ", children=" + children + "]";
    }
}
